package ru.jexp.rcp.supply.swtext;

import java.math.BigDecimal;

import org.eclipse.nebula.widgets.formattedtext.NumberFormatter;

public class DecimalFormatter extends NumberFormatter {

	public static final String EDIT_MASK_6 = "#.######";
	public static final String EDIT_MASK_2 = "#.##";

	public DecimalFormatter(String editMask) {
		super(editMask);
		setFixedLengths(false, true);
	}

	@Override
	public Object getValue() {
		Object value = super.getValue();
		if (value instanceof BigDecimal) {
			return value;
		}
		if (value instanceof Number) {
			return BigDecimal.valueOf(((Number) value).doubleValue());
		}
		return value;
	}

	@Override
	public Class<BigDecimal> getValueType() {
		return BigDecimal.class;
	}
}
